<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
	String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/im";
%>
<script type="text/javascript">
	function showOrHideSearchHitory(){
		var status=document.getElementById("searchHistoryDiv").style.display;
		if(status=="block"){
			document.getElementById("searchHistoryDiv").style.display="none";
		}
		else{
			document.getElementById("searchHistoryDiv").style.display="block";
		}
		var searchHtml='<span style="float:left;margin-top:6px;width:100%;">&nbsp;&nbsp;查找内容：<input id="searchContent" type="text" style="font-family: SimSun; font-size: 12px; padding:0; width:100px;height:15px;" value="<s:property value="#request.searchContent" />"/>&nbsp;<input onclick="getImContentHistory(1);" style="font-size: 12px;height:20px; width:45px" type="button" value="确定"/></span>';
		document.getElementById("searchHistoryDiv").innerHTML="";		
		document.getElementById("searchHistoryDiv").innerHTML=searchHtml;
	}

	function paginationCommonIm(field){
		var initHtml="";
		var pageNumberCommon =parseInt(<s:property value="pager.pageNumber"/>);
		if(isNaN(pageNumberCommon)){
			pageNumberCommon=0;
		} 
		var pageCountCommon=parseInt(<s:property value="#request.pageCount"/>);
		if(isNaN(pageCountCommon)){
			pageCountCommon=0;
		}
		var pageSizeCommon=parseInt(<s:property value="pager.pageSize"/>);
		
		if(isNaN(pageSizeCommon)){
			pageSizeCommon=15;
		}
		
		var totalCommon=parseInt(<s:property value="pager.totalElements"/>);
		if(isNaN(totalCommon)){
			totalCommon=0;
		}
		
		var urlPageCommon=document.getElementById("urlforwardIm").value;
		
		initHtml+='<span id="historyTool" style="float:left;margin-top:6px;"><span style="float:left;cursor: pointer" onclick="showOrHideSearchHitory();">&nbsp;<img align="absmiddle" src="${pageContext.request.contextPath}/cts/images/searchHistory.png" />查找&nbsp;</span><span style="float:left;cursor: pointer" onclick="delImContentHistory();">&nbsp;<img align="absmiddle" src="${pageContext.request.contextPath}/cts/images/del_pic.jpg" />清空&nbsp;</span></span>';
		initHtml+='<span style="float:left;margin-top:6px;" >';
		if(pageNumberCommon>1){
			initHtml+='&nbsp;<img style="cursor: pointer" src="${pageContext.request.contextPath}/cts/images/page-first-disabled01.gif" onclick="javascript:homePage(\''+urlPageCommon+'\','+field+')" />';
			initHtml+='<img style="cursor: pointer" src="${pageContext.request.contextPath}/cts/images/page-prev-disabled01.gif" onclick="javascript:lastPage(\''+urlPageCommon+'\','+field+')" />';
		}else{
			initHtml+='<img src="${pageContext.request.contextPath}/cts/images/page-first-disabled.gif" />';
			initHtml+='<img src="${pageContext.request.contextPath}/cts/images/page-prev-disabled.gif"  />';
		}
		initHtml+='</span>';
		
		initHtml+='<span style="float:left;margin-top:3px;font-family: SimSun; font-size: 12px;" >&nbsp;第&nbsp;';
		initHtml+='<input onkeypress="doPagePressEnter2(\''+urlPageCommon+'\', '+field+', event)" style="font-family: SimSun; font-size: 12px; width: 30px;  padding:0;" type="text" id="pageNumberIm" name="pageNumberIm" class="page-num" value="'+pageNumberCommon+'"/>';
		initHtml+='&nbsp;/&nbsp;'+pageCountCommon+'&nbsp;页</span>';
		
		initHtml+='<span style="float:left;margin-top:6px;" >';
		if(pageNumberCommon < pageCountCommon){
			initHtml+='<img style="cursor: pointer" src="${pageContext.request.contextPath}/cts/images/text-prev-disabled01.gif" onclick="javascript:nextPage(\''+urlPageCommon+'\', '+field+')"/>';
			initHtml+='<img style="cursor: pointer" src="${pageContext.request.contextPath}/cts/images/text-first-disabled01.gif" onclick="javascript:endPage(\''+urlPageCommon+'\','+field+')" />';
		}else{
			initHtml+='<img src="${pageContext.request.contextPath}/cts/images/text-prev-disabled.gif"/>';
			initHtml+='<img src="${pageContext.request.contextPath}/cts/images/text-first-disabled.gif"/>';
		}
		initHtml+='</span>';
		<%--
		initHtml+='<span style="float:right;font-family: SimSun; font-size: 12px;"><s:text name="m68.pageContent3"/>';
		initHtml+='<select style="font-family: SimSun; font-size: 12px;" name="pageSizeIm" id="pageSizeIm" onchange="changePage(this.form,\''+urlPageCommon+'\')">';
		if(pageSizeCommon ==5 ){initHtml+='<option value="5" selected>5</option>';}else{initHtml+='<option value="5">5</option>';}
		if(pageSizeCommon ==10){initHtml+='<option value="10" selected>10</option>';}else{initHtml+='<option value="10">10</option>';}
		if(pageSizeCommon ==15){initHtml+='<option value="15" selected>15</option>';}else{initHtml+='<option value="15">15</option>';}
		if(pageSizeCommon ==20){initHtml+='<option value="20" selected>20</option>';}else{initHtml+='<option value="20">20</option>';}
		if(pageSizeCommon ==25){initHtml+='<option value="25" selected>25</option>';}else{initHtml+='<option value="25">25</option>';}
		if(pageSizeCommon ==30){initHtml+='<option value="30" selected>30</option>';}else{initHtml+='<option value="30">30</option>';}
		initHtml+='</select><s:text name="m68.pageContent4"/>&nbsp;&nbsp;&nbsp;&nbsp;<s:text name="m68.pageContent5"/>'+totalCommon+'<s:text name="m68.pageContent6"/>&nbsp;&nbsp;';
		initHtml+='</span>';
		--%>
		document.getElementById("paginationIm").innerHTML="";		
		document.getElementById("paginationIm").innerHTML=initHtml;
	}
	

        function homePage( url,field){
        	getImContentHistory(1);
  		}
  		
  		function endPage( url ,field){
  			var endCount ='<s:property value="#request.pageCount"/>';
        	getImContentHistory(( parseInt( endCount )));
        	
  			
  		}
        
		function nextPage(url, field){
        	getImContentHistory(( parseInt( document.getElementById( "pageNumberIm" ).value ) + 1 ));
		}
		
		function lastPage( url, field ){
        	getImContentHistory(( parseInt( document.getElementById( "pageNumberIm" ).value ) - 1 ));
	     }	
	     
	    function doPagePressEnter2( url, field, event){
			if (event.keyCode == 13) {
				var pageNumber = $('#pageNumberIm').val();
				var newPar = /^\d+(\.\d+)?$/; 
  				if(!newPar.test(pageNumber)){
  					alert('请输入正确的数字');
  					return;
  				}
	        	getImContentHistory(pageNumber);
			}	
			
	     }
</script>	